# 需求：打开‘注册A.html’页面，完成以下操作
# 1). 填写注册信息
# 2). 截图保存
import time
from time import sleep
from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
# 1.打开浏览器
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.wait import WebDriverWait

driver = webdriver.Chrome(executable_path='chromedriver.exe')
# 2.输入访问地址（URL）
# url = r"D:\UI自动化测试\注册实例.html"
# driver.get(url)
driver.get("http://121.43.169.97:8848/pageA.html")

# 1.填写注册信息
driver.find_element_by_css_selector("#userA").send_keys("admin1")
# 2.截图保存
# 调用截图方法
# driver.get_screenshot_as_file("../img/admin.png")

# 动态获取文件名称，使用时间戳
# driver.get_screenshot_as_file("../img/%s.png" %(time.strftime("%Y_%m_%d_%H_%M_%S")))
driver.get_screenshot_as_file("../img/{}.png".format(time.strftime("%Y_%m_%d_%H_%M_%S")))
sleep(3)
driver.quit()

